package com.cmcc.pcap.packet.dataObtian;

import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @Auther: zdw
 * @Date: 2019-09-25 14:27
 * @Description:
 */
public class ResolveDataObtain {

    private volatile static ResolveDataObtain resolveDataObtain;

    private volatile Queue<HashMap<Object,Object>> dataQueue;

    private ResolveDataObtain(){
        dataQueue = new ConcurrentLinkedQueue<>();
    }

    public static ResolveDataObtain getResolveDataObtain(){
        if (resolveDataObtain == null){
            synchronized (ResolveDataObtain.class){
                if (resolveDataObtain ==null){
                    resolveDataObtain = new ResolveDataObtain();
                }
            }
        }
        return resolveDataObtain;
    }

    public Queue<HashMap<Object,Object>> getData(){
        return dataQueue;
    }

    public boolean haveData(){
        return !dataQueue.isEmpty();
    }

    public synchronized void saveData(HashMap<Object,Object> dataMap){
        dataQueue.poll();
    }
}
